﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace PozrSvc
{
    public partial class SplashScreen : UserControl
    {
        private byte iconIndex = 1;

        public SplashScreen()
        {
            InitializeComponent();
            this.apbLogo.Image = CustomControls.AlphaImage.CreateFromResource("Pozr.Resources.splash_logo.png");
        }

        public void DisplayMessage(string s)
        {
            this.alStatus.Text = s;
            this.apMain.Refresh();
        }

        public void DisplayIcon(CustomControls.AlphaImage icon)
        {
            switch (iconIndex)
            {
                case 1: apbIcon1.Image = icon; break;
                case 2: apbIcon2.Image = icon; break;
                case 3: apbIcon3.Image = icon; break;
                case 4: apbIcon4.Image = icon; break;
                case 5: apbIcon5.Image = icon; break;
            }
            this.apbBackground.Refresh();
            if (iconIndex < 5) iconIndex++;
            else iconIndex = 1;
            this.apMain.Refresh();
        }

        protected override void OnResize(EventArgs e)
        {
            Bitmap bmp = new Bitmap(this.ClientSize.Width, this.ClientSize.Height);

            Graphics g = Graphics.FromImage(bmp);

            g.Clear(Color.Gray);
            Microsoft.Drawing.GradientFill.Fill(g, new Rectangle(0, 0, this.ClientSize.Width, this.ClientSize.Height), Color.Black, Color.FromArgb(80, 80, 80), Microsoft.Drawing.FillDirection.TopToBottom);

            System.IO.MemoryStream stream = new System.IO.MemoryStream();
            bmp.Save(stream, System.Drawing.Imaging.ImageFormat.Bmp);
            this.apbBackground.Image = CustomControls.AlphaImage.CreateFromStream(stream);
            g.Dispose();
            bmp.Dispose();

            this.Refresh();
            base.OnResize(e);
        }
    }
}
